<template>
  <el-dialog :title="$t('query.event.gpsInfo')" width="35%" :visible.sync="gpsInfoVisible">
    <div style="width: 100%; height: 800px; overflow-y: scroll;">

      <el-row>
        <el-col :span="12"><div class="dialog-left-text grid-content">{{$t('query.deviceCode')}}</div></el-col>
        <el-col :span="12"><div class="grid-content" v-text="gpsData.deviceId"></div></el-col>
      </el-row>
      <el-row>
        <el-col :span="12"><div class="dialog-left-text grid-content">{{$t('query.recordTime')}}</div></el-col>
        <el-col :span="12"><div class="grid-content" v-text="parseTime(gpsData.recordTime)"></div></el-col>
      </el-row>
      <el-row>
        <el-col :span="12"><div class="dialog-left-text grid-content">{{$t('query.deviceTime')}}</div></el-col>
        <el-col :span="12"><div class="grid-content" v-text="parseTime(gpsData.deviceTime)"></div></el-col>
      </el-row>

      <el-row>
        <el-col :span="12"><div class="dialog-left-text grid-content">{{$t('query.event.gpsData.locationSource')}}</div></el-col>
        <el-col :span="12"><div class="grid-content" v-text="locationSourceFormat(gpsData.locationSource)"></div></el-col>
      </el-row>
      <el-row>
        <el-col :span="12"><div class="dialog-left-text grid-content">{{$t('query.event.gpsData.dataValidity')}}</div></el-col>
        <el-col :span="12"><div class="grid-content" v-text="dataValidityFormat(gpsData.dataValidity)"></div></el-col>
      </el-row>
      <el-row>
        <el-col :span="12"><div class="dialog-left-text grid-content">{{$t('query.event.gpsData.longitudeSign')}}</div></el-col>
        <el-col :span="12"><div class="grid-content" v-text="longitudeSignFormat(gpsData.longitudeSign)"></div></el-col>
      </el-row>
      <el-row>
        <el-col :span="12"><div class="dialog-left-text grid-content">{{$t('query.event.gpsData.latitudeSign')}}</div></el-col>
        <el-col :span="12"><div class="grid-content" v-text="latitudeSignFormat(gpsData.latitudeSign)"></div></el-col>
      </el-row>
      <el-row>
        <el-col :span="12"><div class="dialog-left-text grid-content">{{$t('query.event.gpsData.satelliteNumber')}}</div></el-col>
        <el-col :span="12"><div class="grid-content" v-text="gpsData.satelliteNumber"></div></el-col>
      </el-row>
      <el-row>
        <el-col :span="12"><div class="dialog-left-text grid-content">{{$t('query.event.gpsData.longitude')}}</div></el-col>
        <el-col :span="12"><div class="grid-content" v-text="gpsData.longitude"></div></el-col>
      </el-row>
      <el-row>
        <el-col :span="12"><div class="dialog-left-text grid-content">{{$t('query.event.gpsData.latitude')}}</div></el-col>
        <el-col :span="12"><div class="grid-content" v-text="gpsData.latitude"></div></el-col>
      </el-row>
      <el-row>
        <el-col :span="12"><div class="dialog-left-text grid-content">{{$t('query.event.gpsData.height')}}</div></el-col>
        <el-col :span="12"><div class="grid-content" v-text="gpsData.height"></div></el-col>
      </el-row>
      <el-row>
        <el-col :span="12"><div class="dialog-left-text grid-content">{{$t('query.event.gpsData.gpsSpeed')}}</div></el-col>
        <el-col :span="12"><div class="grid-content" v-text="gpsData.gpsSpeed"></div></el-col>
      </el-row>
      <el-row>
        <el-col :span="12"><div class="dialog-left-text grid-content">{{$t('query.event.gpsData.course')}}</div></el-col>
        <el-col :span="12"><div class="grid-content" v-text="gpsData.course"></div></el-col>
      </el-row>

    </div>
  </el-dialog>
</template>

<script>
export default {
  name: 'gps',
  data() {
    return {
      gpsData: {},
      gpsInfoVisible: false,
    }
  },

  methods: {
    init(data) {
      this.gpsData = data
      this.gpsInfoVisible = true
    },

    locationSourceFormat(data) {
      switch (data) {
        case 0:
          return "GPS"
        case 1:
          return "GSM"
        default:
          return data
      }
    },
    dataValidityFormat(data) {
      switch (data) {
        case 0:
          return this.$t('query.event.gpsData.realTime')
        case 1:
          return this.$t('query.event.gpsData.lastTime')
        default:
          return data
      }
    },
    longitudeSignFormat(data) {
      switch (data) {
        case 0:
          return this.$t('query.event.gpsData.eastLongitude')
        case 1:
          return this.$t('query.event.gpsData.westLongitude')
        default:
          return data
      }
    },
    latitudeSignFormat(data) {
      switch (data) {
        case 0:
          return "南纬"
        case 1:
          return "北纬"
        default:
          return data
      }
    },
  }
}
</script>

<style lang="scss" scoped>
.dialog-left-text {
  padding-left: 50px;
  font-weight: bold;
  font-family: "Helvetica Neue",Helvetica,"PingFang SC","Hiragino Sans GB","Microsoft YaHei","微软雅黑",Arial,sans-serif;
}
.el-row {
  margin-bottom: 20px;
  &:last-child {
    margin-bottom: 0;
  }
}
.el-col {
  border-radius: 4px;
}
.grid-content {
  border-radius: 4px;
  min-height: 36px;
}
.row-bg {
  padding: 10px 0;
}
</style>
